<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTallyTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tally', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('code', 16)->unique()->comment('理货单');
            $table->unsignedBigInteger('product_id')->comment('产品id');
            $table->string('barcode', 64)->comment('产品条码');
            $table->unsignedBigInteger('warehousing_id')->comment('入库单号');
            $table->unsignedInteger('quantity')->comment('预期数量');
            $table->unsignedInteger('send')->default(0)->comment('收货数量');
            $table->unsignedTinyInteger('status')->default(0)->comment('状态: 0:待理货 1:理货中 2:理货完成');

            $table->unique(['warehousing_id', 'product_id']);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tally');
    }
}
